<?php

/*
 * Niken Larasati
 * larasati.n@students.amikom.ac.id
 */

class kematian_m extends CI_Model{
    public function __construct() {
        parent::__construct();
    }
    
    function ambil_data(){
        $this->db->select('kematian.idkematian as idkematian,'
                . 'kematian.no_form as no_form, '
                . 'penduduk.nik as nik_mati,'
                . 'penduduk.nama as nama_mati,'
                . 'jenis_kelamin.jenis_kelamin as jenis_kelamin,'
                . 'kk.no_kk as no_kk,'
                . 'kk.dusun as dusun, '
                . 'kematian.tgl_mati as tgl_mati,'
                . 'kematian.sebab as sebab,'
                . 'kematian.penerang as penerang,'
                . 'kematian.nama_pelapor as nama_pelapor,');
        $this->db->from('kematian');
        $this->db->join('penduduk','kematian.nik=penduduk.nik','left');
        $this->db->join('jenis_kelamin','penduduk.idjenis_kelamin=jenis_kelamin.idjenis_kelamin','left'); //jk->penduduk ada 3 tabel; kematian->penduduk->jk
        $this->db->join('kk','kematian.no_kk=kk.no_kk','left');
        $this->db->order_by('kematian.tgl_mati', 'desc');
        return $this->db->get();
    }
    
    function detail_cari($parameter = NULL){
        $this->db->select('kematian.idkematian as idkematian,'
                . 'kematian.no_form as no_form, '
                . 'penduduk.nik as nik_mati,'
                . 'penduduk.nama as nama_mati,'
                . 'jenis_kelamin.jenis_kelamin as jenis_kelamin,'
                . 'kk.no_kk as no_kk,'
                . 'kk.dusun as dusun, '
                . 'kematian.tgl_mati as tgl_mati,'
                . 'kematian.sebab as sebab,'
                . 'kematian.penerang as penerang,'
                . 'kematian.nama_pelapor as nama_pelapor,');
        $this->db->from('kematian');
        $this->db->join('penduduk','kematian.nik=penduduk.nik','left');
        $this->db->join('jenis_kelamin','penduduk.idjenis_kelamin=jenis_kelamin.idjenis_kelamin','left'); //jk->penduduk ada 3 tabel; kematian->penduduk->jk
        $this->db->join('kk','kematian.no_kk=kk.no_kk','left');
        $this->db->order_by('kematian.tgl_mati', 'desc');
        
        if($parameter != NULL){
            $this->db->where($parameter);
        }
        return $this->db->get();
    }
}
?>

